# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: Dario Klingenberg <dario.klingenberg@web.de>
# Contributor: Kaare Jenssen <kaare@jenssen.it>
# Contributor: Julian DeMille <julian.demille@demilletech.net>
# Contributor: Alexander F Rødseth <xyproto@archlinux.org>
# Contributor: Chris Dunder <cdunder@gmail.com>
# Contributor: M Rawash <mrawash@gmail.com>
# Contributor: olvar <beren.olvar@gmail.com>
# Contributor: Andrew Antle <andrew.antle@gmail.com>
# Contributor: joyfulgirl <joyfulgirl@archlinux.us>
# Contributor: Jonathan Friedman <jonf@gojon.com>
# Contributor: Stefan Husmann <stefan-husmann@t-online.de>
# Contributor: sidereus <francesco.serafin.3@gmail.com>

pkgname=stumpwm
pkgver=22.11
pkgrel=5
pkgdesc='Tiling, keyboard-driven window manager written in Common Lisp'
arch=('loong64' 'x86_64')
url='https://stumpwm.github.io/'
license=('GPL2')
depends=(
  'glibc'
  'zstd'
  'sbcl'
  'cl-ppcre'
  'cl-clx'
  'cl-alexandria'
)
makedepends=('git' 'texlive-bin' 'texlive-plaingeneric')
optdepends=(
  'emacs: edit and eval stumpwm code with M-x stumpwm-mode'
  'stumpwm-contrib: extension modules for StumpWM'
)
options=('!strip' '!makeflags')
_commit='fff2508fd54b4035b0d80bafbd75a13f1756130f'
source=(
  "$pkgname::git+https://github.com/stumpwm/stumpwm#commit=$_commit"
  'stumpwm.desktop'
)
b2sums=('SKIP'
        'a6bf8083d300854c4252046937e18bea935b4bd496677b8bcf0ca74c3af91f37dcd0f7ce766b23ac0b22a9fbbec40d55ca2804c8ecf46db087cc1842116d8f6c')

pkgver() {
  cd "$pkgname"

  git describe --tags | sed -e 's/^v//' -e 's/-/.r/' -e 's/-/./g'
}

build() {
  cd "$pkgname"

  autoconf

  ./configure \
    --prefix=/usr \
    --with-module-dir=/usr/share/stumpwm/contrib

  make

  # generate html/pdf documentation
  makeinfo --pdf stumpwm.texi
  makeinfo --html stumpwm.texi
}

package() {
  cd "$pkgname"

  make destdir="$pkgdir" install

  # documentation
  install -vDm644 -t "$pkgdir/usr/share/doc/$pkgname" \
    sample-stumpwmrc.lisp README.md stumpwm.pdf
  cp -vr stumpwm_html "$pkgdir/usr/share/doc/$pkgname/html"

  # desktop file
  install -vDm644 -t "$pkgdir/usr/share/xsessions" ../stumpwm.desktop
}
